package com.yitongmao.common.reminder;/*
* 作者：梁伟航 on 2017/7/5 15:24
* 类的用途：
*/

import android.content.Context;
import android.support.multidex.MultiDex;

import com.yitongmao.common.CrashHandler;
import com.yitongmao.core.cache.ACache;

import org.litepal.LitePal;
import org.litepal.LitePalApplication;
import org.litepal.exceptions.GlobalException;


public class ReaderApplication extends LitePalApplication {
     static Context mBase;
    public static ReaderApplication applicationContext;

    public static ReaderApplication getInstace() {
        return applicationContext;
    }

    public ACache mCache;
    @Override
    public void onCreate() {
        super.onCreate();
        applicationContext = this;
        mCache = ACache.get(applicationContext);
        CrashHandler.getInstance().init(this);
    }
    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }
  /*  @Override
    public Context getApplicationContext() {
        return mBase.getApplicationContext();
    }
*/

    /**
     * Construct of LitePalApplication. Initialize application context.
     */
    public ReaderApplication() {
        mBase = this;
    }

    /**
     * Deprecated. Use {@link LitePal#initialize(Context)} instead.
     * @param context
     * 		Application context.
     */
    @Deprecated
    public static void initialize(Context context) {
        mBase = context;
    }

    /**
     * Get the global application context.
     *
     * @return Application context.
     * @throws org.litepal.exceptions.GlobalException
     */
    public static Context getContext() {
        if (mBase == null) {
            throw new GlobalException(GlobalException.APPLICATION_CONTEXT_IS_NULL);
        }
        return mBase;
    }
}
